package com.bioscript.standalone.dataStructures;

import java.util.Comparator;
public class SimpleRangeComparator implements Comparator<Range>
{
	@Override
	public int compare(Range o1, Range o2) {
		int o1_start = o1.getLowerLimit();
		int o1_end = o1.getUpperLimit();
		int o2_start = o2.getLowerLimit();
		int o2_end = o2.getUpperLimit();
			
		if (o1.isReverse())
		{
			o1_start = o1.getUpperLimit();
			o1_end = o1.getLowerLimit();
		}
		if (o2.isReverse())
		{
			o2_start = o2.getUpperLimit();
			o2_end = o2.getLowerLimit();
		}
		
		int diff =  o1_start - o2_start;
		if (diff == 0)
		{
			diff = o1_end - o2_end;
		}
		return diff;
	}
}	
